from core.support import set_cutscene
from core.item import Item
from core.action import Action

class Wallet(Item):
    def __init__(self):
        Item.__init__(self, "wallet")    # do basic initialization for every item
        self.has_cash = True
                
        # build list of actions
        self.add_action(UseCash)
    
    def get_description(self):
            return "wallet"

# define actions for this item

class UseCash(Action):
    def __init__(self):
        Action.__init__(self, "use_cash")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Use Cash"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # only works in basement. add cutscene
    def do_action(self,game,room,request):
        if self.item.has_cash:
            if room.get_id() == 'basement':
                if room.lock_rusty:
                    set_cutscene("You use some cash to tip the bartender.")
                    self.item.has_cash = False
                    room.lock_rusty = False
            else:
                set_cutscene("You used all of your cash to tip the bartender. You now have no cash for a cab ride home.")
                self.item.has_cash = False
        else:
            set_cutscene("You look in your wallet and find only napkins with phone numbers written in lipstick.")
        return